package com.ucs.ui;

import java.util.List;
import java.util.Map;

import com.ucs.domain.Item;
import com.ucs.domain.OrderDetail;
import com.ucs.util.UCSData;

import android.content.Context;
import android.util.Log;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;

public class OrderDetailListAdaptor extends ArrayAdapter<OrderDetail>{
    private List<OrderDetail> orderDetails;
	Map<Integer, Item> id2ItemMap = UCSData.getInstance().getId2ItemMap();

    public OrderDetailListAdaptor(Context context, int textViewResourceId, List<OrderDetail> orderDetails) {
        super(context, textViewResourceId, orderDetails);
        this.orderDetails = orderDetails;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parentView) {
		if (convertView == null){
			convertView = CategoryItemListAdaptor.getGenericView(parentView, 30, 20);
		}
    	OrderDetail orderDetail = orderDetails.get(position);
    	Log.d("ucs", "orderDetails.size()="+orderDetails.size()+ ", position="+position+", "+"itemID="+orderDetail.getItemID());
		Item item = id2ItemMap.get(orderDetail.getItemID());
		((TextView)convertView).setText(item.getName1());            
		return convertView;           
    }
}
